package com.aiit.controller;

import cn.hutool.core.util.ObjectUtil;
import com.aiit.pojo.User;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: LuTao
 * @Date: 2022/05/04/10:43
 */
@Controller
public class ViewController {

    //后台主界面
    @RequestMapping("index02")
    public String test(){
        return "admin/index";
    }

    //后台用户管理界面
    @RequestMapping("/admin/user")
    public String user(){
        return "admin/usermanage/user";
    }
    //后台公司管理界面
    @RequestMapping("/admin/company")
    public String company(){
        return "admin/companymanage/company";
    }
    //后台岗位管理
    @RequestMapping("/admin/job")
    public String job(){
        return "admin/jobmanage/job";
    }
    //后台简介管理
    @RequestMapping("/admin/resume")
    public String Resume(){
        return "admin/resumemanage/resume";
    }

    //注册界面
    @GetMapping("/register")
    public String toRegister(){
        return "register";
    }

    //登陆界面
    @GetMapping("/login")
    public String toLogin(){
        return "login";
    }

    //主界面
    @GetMapping({"/","/index"})
    public String toIndex(Model model){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        if(ObjectUtil.isNotNull(user)){
            model.addAttribute("userInfo",user);
        }
        return "index";
    }
}
